#!/bin/bash

hg clone http://nooneshome.org/privatehg/sasc-ng
tar xvzf /usr/portage/distfiles/vdr-sc-0.8.6.tar.gz 
tar xvzf /usr/portage/distfiles/vdr-sc-0.8.7.tar.gz 

d=`date +"%m_%d_%Y"`

ORG="./sasc-ng/sc/PLUGINS/src/sc-src/systems/nagra.vdr-sc"
NEW="./sasc-ng/sc/PLUGINS/src/sc-src/systems/nagra"
SC_VER="0.8.6"
SC_SRC="./sc-$SC_VER/systems/nagra"

echo "SC_SRC: $SC_SRC"
echo "Copy to dir: $ORG"
echo "New dir: $NEW"

P_FILE="sasc_src_$d-$SC_VER.patch"

cp -r $SC_SRC $ORG
diff -Naur $ORG $NEW > $P_FILE
sed -i -e "s:$ORG:systems/nagra.org:g" $P_FILE
sed -i -e "s:$NEW:systems/nagra:g" $P_FILE

rm -rf $ORG

SC_VER="0.8.7"
SC_SRC="./sc-$SC_VER/systems/nagra"
P_FILE="sasc_src_$d-$SC_VER.patch"

echo "Processing: $SC_SRC"

cp -r $SC_SRC $ORG
diff -Naur $ORG $NEW > $P_FILE
sed -i -e "s:$ORG:systems/nagra.org:g" $P_FILE
sed -i -e "s:$NEW:systems/nagra:g" $P_FILE
